package com.lehecai.core.api.event;

import com.lehecai.core.IntegerBeanLabelItem;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;

/**
 *
 */
public class PropInfoStatus extends IntegerBeanLabelItem {

    private static final Logger logger = LoggerFactory.getLogger(PropType.class.getName());

    private static List<PropInfoStatus> items = new ArrayList<PropInfoStatus>();
    private static List<PropInfoStatus> queryItems = new ArrayList<PropInfoStatus>();

    protected PropInfoStatus(String name, int value, boolean queryOnly) {
        super(PropInfoStatus.class.getName(), name, value);
        queryItems.add(this);
        if (!queryOnly) {
            items.add(this);
        }
    }

    protected PropInfoStatus(String name, int value) {
        this(name, value, false);
    }

    public static PropInfoStatus getItem(int value){
        try {
            return (PropInfoStatus) PropInfoStatus.getResult(PropInfoStatus.class.getName(), value);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return null;
        }
    }

    public static List<PropInfoStatus> getItems() {
        return items;
    }

    public static List<PropInfoStatus> getQueryItems() {
        return queryItems;
    }

    public static final PropInfoStatus ALL = new PropInfoStatus("全部", -1, true);
    public static final PropInfoStatus NORMAL = new PropInfoStatus("正常", 0);
    public static final PropInfoStatus USED = new PropInfoStatus("已使用", 1);
    public static final PropInfoStatus EXPIRED = new PropInfoStatus("过期", 2);
}
